//
//  XMLGetSensitivity.m
//  Seizure
//
//  Created by student on 3/22/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "XMLGetSensitivity.h"

@implementation XMLGetSensitivity

@synthesize currentElementValue;
@synthesize sensitivity;

NSMutableString *xml;
- (NSMutableString *)xml
{
    return xml;
}

BOOL insideSensitivity = NO;

static NSString *xSensitivity = @"sensitivity";

- (id) init{
    xml = [[NSMutableString alloc] init ];
    if (self = [super init]){
        sensitivity = [[NSNumber alloc]init]; 
        currentElementValue = [[NSMutableString alloc] init ];
    }
    return self;
}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI
 qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
{
    if ([elementName isEqualToString:xSensitivity])
    {
        //NSLog(@"Entering sensitivity");
        insideSensitivity = YES;
    }

}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI
 qualifiedName:(NSString *)qName
{
    if([elementName isEqualToString:xSensitivity] && insideSensitivity)
    {
        sensitivity = [NSNumber numberWithInt:[xml integerValue]];
    }
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{    
    [xml appendString:string];
}

@end
